import os
import json

path = '/home/kyrie/master_paper/dataset/merge_file'
sensor_list = ['cegun', 'chilunxiang', 'dianjichui', 'dianjiheng', 'fuchen', 'hengjian', 'hengxiang', 'lingxing',
               'niuzhuan', 'qianyin', 'zhidong', '角速度', '_速度']
dict = {}
for sensor in sensor_list:
    # print('以下是%s数据：' % sensor)
    temp_list = []
    for roots, dirs, files in os.walk(path):
        for ifile in files:
            tempfile = roots + '/' + ifile
            if tempfile.find(sensor) != -1:
                temp_list.append(tempfile)
    # print(temp_list)
    temp_list.sort()
    dict[sensor] = temp_list
print(dict)

json_path = '/home/kyrie/master_paper/dataset/merge_file/jsonfile.json'
with open(json_path, 'w') as jf:
    json.dump(dict, jf, sort_keys=True, indent=4, separators=(',', ':'), ensure_ascii=False)
